# contrib/devinsight/Makefile

MODULE_big = devinsight
OBJS = utils.o devinsight.o ustore.o astore.o segment.o lock.o optimizer.o \
       xlog.o buffer.o

PG_CPPFLAGS = -I$(libpq_srcdir)
SHLIB_LINK_INTERNAL = $(libpq)

EXTENSION = devinsight
DATA = devinsight--1.0.sql

REGRESS = devinsight

# the db name is hard-coded in the tests
override USE_MODULE_DB =

gen_dev_func_desc:
	@echo "generate devinsight function description ..."
	@grep DVI_DEF_SQL_FUNCTION * -Rh --exclude=devinsight.h --exclude=Makefile | sed 's/DVI_DEF_SQL_FUNCTION(\([^,]*\), "\(.*\)")/DviFunctionDesc("SQL", "\1", "\2"),/g' >> dev_func_desc.txt
	@grep DVI_DEF_GDB_FUNCTION * -Rh --exclude=devinsight.h --exclude=Makefile | sed 's/DVI_DEF_GDB_FUNCTION(\([^,]*\), "\(.*\)")/DviFunctionDesc("GDB", "\1", "\2"),/g' >> dev_func_desc.txt

dev_func_desc.txt:
	@$(MAKE) gen_dev_func_desce


all: objfiles.txt
     
 # generate postgres_fdw objfiles.txt to suspend duplicate make of gaussdb
objfiles.txt: $(OBJS)
	@echo "" > objfiles.txt

objfiles_clean:
	rm -f objfiles.txt

clean: objfiles_clean

ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
SHLIB_PREREQS = submake-libpq
subdir = contrib/devinsight
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

exclude_option=-fPIE
override CPPFLAGS := $(filter-out $(exclude_option),$(CPPFLAGS))
